int armLevelTarget;
int lpot_baseline;
int rpot_baseline;
int state = 0;

void arm_init();

task arm_automate()
{
  int error;
  arm_init();
  state = 1;
  while(SensorValue(lpot) < lpot_baseline + armLevelTarget)
  {
    error = rpot_baseline + armLevelTarget - SensorValue(lpot);
    motor[leftArm1] = 128;
    motor[leftArm2] = -128;
  }
  while(SensorValue(rpot) > rpot_baseline - armLevelTarget)
        {
          error = rpot_baseline - armLevelTarget - SensorValue(rpot);
    motor[rightArm1] = -128;
    motor[rightArm2] = 128;
  }
  state = 0;
}

void arm_init()
{
  lpot_baseline = SensorValue(lpot);
  rpot_baseline = SensorValue(rpot);
}
 
